//
//  TravelWebViewController.m
//  TripGroup
//
//  Created by apple on 15/10/24.
//  Copyright © 2015年 lanou3g.com蓝鸥科技有限公司. All rights reserved.
//

#import "TravelWebViewController.h"
#import "UMSocial.h"
@interface TravelWebViewController ()<UIWebViewDelegate,UMSocialUIDelegate>
@property (nonatomic, strong) UIBarButtonItem *shareBtn;
@end

@implementation TravelWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBarHidden = NO;
    self.navigationItem.title = @"去旅游";
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    self.webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    NSURL *url = [NSURL URLWithString:self.webStr];
    NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15];
    self.webView.delegate = self;
    [self.webView loadRequest:request];
    [self.view addSubview:self.webView];
    
    UIButton *rightBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
    [rightBtn setBackgroundImage:[UIImage imageNamed:@"newshare.png"] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(shareDetailInfo) forControlEvents:UIControlEventTouchUpInside];
    
    _shareBtn = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
    self.navigationItem.rightBarButtonItem = self.shareBtn;

}
- (void)shareDetailInfo
{
    // 分享
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"561c5f76e0f55ab642001b90"
                                      shareText:[NSString stringWithFormat:@"来一场说走就走的旅行吧！\n%@",self.webStr]
                                     shareImage:[UIImage imageNamed:@"icon.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToRenren,UMShareToDouban,nil]
                                       delegate:self];
}


- (void)webViewDidFinishLoad:(UIWebView *)webView
{
   [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
